{{extend 'layout.html'}}
{{

def generateBookBlock(newBooks, index):}}
        <TD width="33%" style="text-align:center; padding: 20px"><A href="{{=URL(r=request, c="books", f="book", args=[newBooks[index].id])}}">{{=newBooks[index].title}}</A>
    <BR/>
    <IMG width="80" height="100" src="{{=URL(r=request, c="books", f="photo", args=[newBooks[index].id])}}"/>
    <BR/>
    <B>Author:</B>{{=newBooks[index].author}}
    <BR/>
    <B>ISBN:</B>{{=newBooks[index].ISBN}}
    </TD>
{{return}}

{{if request.vars.has_key('error'):}}
<div align="center" style="background-color:red; text-decoration: blink;color: white">{{=request.vars['error']}}</div>
{{pass}}
<div align="right"><FORM method="POST" action="default/search"><INPUT type="text" size="20" name="searchKey" />
<INPUT type="submit" value="Search" name="search" /></FORM></div>
<div class="left">
<h1>Newly added books</h1>
<div align="center">
<table width="80%">
{{end=0}}
{{for i in range(len(newBooks)/3):}}

<TR style="padding:20px">
{{
    for k in range(3):
    index = (i*3) + k
    generateBookBlock(newBooks, index)
    pass
}}
</TR>
{{
    end += 1
    pass
}}

{{if len(newBooks) % 3:}}
<TR style="padding:20px">
{{
    for k in range(len(newBooks) - (end * 3)):
    index = (end*3) + k
    generateBookBlock(newBooks, index)
    pass
}}

</TR>
{{pass}}

</table>
</div>
</div>

<div class="left">
<h1>What's up? </h1>
<UL>
{{for logEntry in logs:}}
<LI>{{=logEntry}}</LI>
{{pass}}
</UL>
